<?php
/**
 * Created by PhpStorm.
 * User: chniccs
 * Date: 2019-11-11
 * Time: 16:26
 */

namespace app\admin\controller;



use app\model\AdminDistrimoney;
use app\util\ReturnCode;

class Distribution extends Base

{
    public function get()
    {
        $model = AdminDistrimoney::get($this->getUserTid());
        if($model){
            $data = $model->getData();
            return $this->buildSuccess($data, '操作成功');
        }else{
            return $this->buildFailed(ReturnCode::FAILED, '未设置佣金数据，请先设置开启，并保存');
        }

    }

    public function save()
    {
        $postData = $this->request->post();
        $postData = $this->addTid($postData);
        $result = AdminDistrimoney::doSave($postData);
        if ($result) {
            return $this->buildSuccess(null, '操作成功');
        } else {
            return $this->buildFailed(ReturnCode::UPDATE_FAILED, '更新失败');
        }
    }
}